/*--------------------------------------------------------------------------------*/
#ifndef __MATH_VECTOR_2__
#define __MATH_VECTOR_2__
/*--------------------------------------------------------------------------------*/
#include "primitives.h"
#include "object.h"
#include "ref_to_.h"
#include "util.h"
#include "defs.h"
#include "math_defs.h"
/*--------------------------------------------------------------------------------*/
class MATH_VECTOR_2
{

    // -- PUBLIC

public:

    // .. CONSTRUCTORS

    MATH_VECTOR_2() :
        X( 0.0f ),
        Y( 0.0f )
    {
    }

    MATH_VECTOR_2( const REAL & x, const REAL & y  ) :
        X( x ),
        Y( y )
    {
    }

    MATH_VECTOR_2( const MATH_VECTOR_2 & other ) :
        X( other.X ),
        Y( other.Y )
    {
    }

    ~MATH_VECTOR_2()
	{
	}

    // .. METHODS

    VOID Set( const REAL & x, const REAL & y )
    {
        X = x;
        Y = y;
    }

    REAL GetDistance( const MATH_VECTOR_2 & other )
    {
    	return MATH_GetSquareRoot( ( other.Y - Y ) * ( other.Y - Y ) + ( other.X - X ) * ( other.X - X ) );
    }

    BOOL IsZero() const
    {
    	return X == 0.0f && Y == 0.0f;
    }

    // .. OPERATORS

    MATH_VECTOR_2 & operator=( const MATH_VECTOR_2 & other )
    {
        X = other.X;
        Y = other.Y;

        return *this;
    }

    MATH_VECTOR_2 & operator+=( const MATH_VECTOR_2 & other )
    {
        X += other.X;
        Y += other.Y;

        return *this;
    }

    MATH_VECTOR_2 & operator-=( const MATH_VECTOR_2 & other )
    {
        X -= other.X;
        Y -= other.Y;

        return *this;
    }

    MATH_VECTOR_2 & operator*=( const REAL & value )
    {
        X *= value;
        Y *= value;

        return *this;
    }

    MATH_VECTOR_2 & operator/=( const REAL & value )
    {
        X /= value;
        Y /= value;

        return *this;
    }

    const MATH_VECTOR_2 operator+( const MATH_VECTOR_2 & other ) const
    {
        return MATH_VECTOR_2( X + other.X, Y + other.Y );
    }

    MATH_VECTOR_2 operator+( const MATH_VECTOR_2 & other )
    {
        return MATH_VECTOR_2( X + other.X, Y + other.Y );
    }

    MATH_VECTOR_2 operator-( const MATH_VECTOR_2 & other )
    {
        return MATH_VECTOR_2( X - other.X, Y - other.Y );
    }

    MATH_VECTOR_2 operator*( const REAL & real )
    {
        return MATH_VECTOR_2( X * real, Y * real );
    }

    MATH_VECTOR_2 operator/( const REAL & real )
    {
        return MATH_VECTOR_2( X / real, Y / real );
    }
    
    BOOL operator==( const MATH_VECTOR_2 & other ) const
    {
    	return X == other.X && Y == other.Y;
    }

    // .. ATTRIBUTES

    REAL
		X,
		Y;

    static MATH_VECTOR_2
		Zero;

};
/*--------------------------------------------------------------------------------*/
#endif


